package what.basic.table;
import javax.swing.*;

import java.awt.*;

import javax.swing.event.*;
import java.awt.event.*;
import javax.swing.table.*;
import what.basic.basiccomponent.*;
public class Jusertablecellrenderer extends JTable {
Jusertablecellrenderer(){
	JFrame f=new Jframe().jframe("tablecellrenderer test",300,300,true);
	Object[][] st={
			{"wangpeng",new Integer(91),new Integer(100)}
			,{"zhuxuelian",new Integer(82),new Integer(69)},
			{"meiting",new Integer(47),new Integer(57)},
	};
	String[] names={"name","yuwen","shuxue"};
	setPreferredScrollableViewportSize(new Dimension(550,30));
	setModel(new DefaultTableModel(st,names){
		public boolean isCellEditable(int rowIndex,int columnIndex){
			if(columnIndex==0)
				return false;
			return true;
		}
	});
	JScrollPane sp=new JScrollPane(this);
	f.getContentPane().add(sp,BorderLayout.CENTER);
	setRowHeight(1,super.getRowHeight()*4);
	f.pack();
}
public TableCellRenderer getCellRenderer(int row,int col){
	if(row==1 && col==2){
		return new TableCellRenderer(){
			JTable subTable=new JTable(new DefaultTableModel(4,4));
			public Component getTableCellRendererComponent(JTable table,
					Object value,boolean isSelected,
					boolean hasFocus,int row, int column){
				return subTable;
			}
		};
	}
	else
		return super.getCellRenderer(row, col);
}
public static void main(String[] args) {
	new Jusertablecellrenderer();
	}

}
